<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>配置单审核</title>
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <link rel="stylesheet" href="../../css/bootstrap-table.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="../../js/bootstrap-table.min.js"></script>
    <script src="../../js/bootstrap.min.js"></script>
    <script src="../../js/bootstrap-table-zh-CN.min.js"></script>
    <script>
        $(function () {
            $("#tab").bootstrapTable({
                method: "get",
                contentType: "application/json;charset=utf-8",
                url: "/scell/queryScellCheck",
                striped: true,
                pageNumber: 1,
                pagination: true,
                sidePagination: 'server',
                pageSize: 3,
                pageList: [3, 5, 6, 10],
                queryParams: function (params) {
                    return {
                        // 计算页号(当前页)
                        pageNumber: (params.offset / params.limit) + 1,
                        // 计算页大小
                        pageSize: params.limit,
                    }
                },
                columns: [
                    {title: '配置单编号', field: 'storeId', align: 'center'},
                    {title: '产品编号', field: 'productId', align: 'center'},
                    {title: '产品名称', field: 'productName', align: 'center'},
                    {title: 'I级分类', field: 'firstKindName', align: 'center'},
                    {title: 'II级分类', field: 'secondKindName', align: 'center'},
                    {title: 'III级分类', field: 'thirdKindName', align: 'center'},
                    {title: '登记时间',field: 'registerTime',align: 'center'},
                    {title: '操作',field: 'id',align: 'center',
                        formatter: function (value, row, index) {
                            var btn1="<button  class='btn btn-primary btn-sm' onclick='audit("+JSON.stringify(row)+")' data-toggle='modal' data-target='#myModal2'>审核</button>";
                            return btn1;
                        }
                    },
                ]
            })
        });
        function findAcc() {
            $.ajax({
                type:'post',
                url:'/SysUser/queryUser',
                success:function (result) {
                    $("#checker").val(result.loginId);
                }
            })
        }

        function audit(data) {
            findAcc();
            var date = new Date();
            let year = date.getFullYear();
            let month = date.getMonth() + 1;
            let day=date.getDate();
            let odate = date.getDate();
            let hour = date.getHours()
            let minute = date.getMinutes()
            let second = date.getSeconds()
            var dataStr=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
            $("#kxMax").val(data.maxAmount);
            $("#kxMin").val(data.minAmount);
            $("#inputname").val(data.productName);
            $("#inputid").val(data.productId);
            let id= data.firstKindId+"-"+data.secondKindId+"-"+data.thirdKindId
            let name=data.firstKindName+"-"+data.secondKindName+"-"+data.thirdKindName;
            $("#tbody").html("");
            $("#tbody").append("<tr><td>" +
                data.id+"</td><td>" +
                "成品库</td><td>" +
                id+"</td><td>" +
                name+"</td><td>" +
                "<input id='Maxcount' value='"+data.maxCapacityAmount+"' style=\"width: 100%;\" class=\"form-control-plaintext\"></td>" +
                "</tr>")
            $("#date").val(dataStr);
            $("#storeId").val(data.storeId);
            $("#config").val(data.config);
        }
        function review() {
                $.ajax({
                    type:'post',
                    url: '/scell/reviewOk',
                    data:"storeId="+$("#storeId").val()+"&checker="+$("#checker").val(),
                    success:function (result) {
                        if(result==1){
                            alert("复核成功");
                            $("#tab").bootstrapTable("refresh");
                        }
                    }
                })
        }
        function reviewNo() {
            $.ajax({
                type:'post',
                url: '/scell/reviewCellNo',
                data:"storeId="+$("#storeId").val()+"&checker="+$("#checker").val(),
                success:function (result) {
                    if(result==1){
                        alert("复核成功");
                        $("#tab").bootstrapTable("refresh");
                    }
                }
            })
        }
    </script>
</head>
<body>
<table id="tab">

</table>
<div class="modal fade" id="myModal2">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">

            <!-- 模态框头部 -->
            <div class="modal-header">
                <h4 class="modal-title" style="margin-left: 43%;">安全库存配置单</h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>

            <!-- 模态框主体 -->
            <div class="modal-body">


                <div class="form-group row">

                    <label for="storeId" class="col-sm-2 col-form-label">库存编号</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" id="storeId" readonly>
                    </div>
                </div>

                <div class="form-group row">

                    <label for="inputname" class="col-sm-2 col-form-label">产品名称</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" id="inputname" readonly>
                    </div>
                    <div class="col-2"></div>
                    <label for="inputid" class="col-sm-2 col-form-label">产品编号</label>
                    <div class="col-sm-3">
                        <input type="text   " class="form-control" id="inputid" readonly>
                    </div>
                </div>

                <div class="form-group row">

                    <label for="kxMin" class="col-sm-2 col-form-label">库存报警下限数：</label>
                    <div class="col-sm-3">
                        <input type="number" class="form-control" id="kxMin" >
                    </div>
                    <div class="col-2">
                    </div>
                    <label for="kxMax" class="col-sm-2 col-form-label">库存报警上限数：</label>
                    <div class="col-sm-3 container" >
                        <input type="number" class="form-control " id="kxMax"data-toggle="tooltip" data-placement="top" data-content="提示" >
                    </div>
                </div>

                <div class="form-group row">


                </div>


                <div>
                    <table class="table table-striped" border="1">
                        <thead class="table-primary ">
                        <tr>
                            <td>序号</td>
                            <td>库房名称</td>
                            <td>存储地址编号</td>
                            <td>存在地址名称</td>
                            <td>最大存储量</td>

                        </tr>
                        </thead>
                        <tbody id="tbody">

                        </tbody>
                    </table>
                </div>

                <div class="form-group row">

                    <label for="checker" class="col-sm-2 col-form-label">复核人：</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" id="checker" readonly>
                    </div>
                    <div class="col-2"></div>
                    <label for="date" class="col-sm-2 col-form-label">复核时间：</label>
                    <div class="col-sm-3">
                        <input type="datetime" class="form-control" id="date" >
                    </div>
                </div>

                <div class="form-group">
                    <label for="config">配置需求</label>
                    <textarea class="form-control" id="config" rows="3"></textarea>
                </div>

            </div>

            <!-- 模态框底部 -->
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="review()">复核通过</button>
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="reviewNo()">复核不通过</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
            </div>

        </div>
    </div>
</div>


</body>
</html>